import 'package:flutter/widgets.dart';

class DetectorFocus extends StatelessWidget {
  const DetectorFocus({
    Key? key, 
    this.blankNode, 
    this.child
  }) : super(key: key);

  final FocusNode? blankNode;
  final Widget? child;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: (){
          // 点击空白页面关闭键盘
          FocusScope.of(context).requestFocus(blankNode ?? FocusNode());
        },
        child: child,
    );
  }
}